This tutorial will show you how to monitor the connection to the platform.
Setting up monitoring
The main Syncano
object has a Monitor
property that exposes methods for monitoring the network connection. To set up the monitor, use the startMonitoring
method:
let connection = Syncano();
connection.Monitor.startMonitoring();
Listening for events
The monitor exposes an EventEmitter
so you can listen for the connected
and disconnected
events:
connection.Monitor.on('connected', () => {
// connected to the api
});
connection.Monitor.on('disconnected', (error) => {
// connection to the api lost
});
Stopping monitoring
To stop monitoring the connection, use the stopMonitoring
method:
connection.Monitor.stopMonitoring();